package com.kedacom.demo.healthcheck;

import java.io.File;

import org.springframework.beans.factory.annotation.Value;

/**
 * GlusterFS健康检查
 * @author luocanfeng
 * @date 2016年9月2日
 */
public class GlusterFSHealthCheckItem extends HealthCheckItem {

	/** GlusterFS校验文件路径 */
	@Value("glusterfs.state.file")
	private String glusterFSCheckFile;

	{
		type = Type.GlusterFS;
	}

	public GlusterFSHealthCheckItem() {
		type = Type.GlusterFS;
	}

	public GlusterFSHealthCheckItem(String name) {
		this();
		this.name = name;
	}

	public GlusterFSHealthCheckItem(String name, String glusterFSCheckFile) {
		this(name);
		this.glusterFSCheckFile = glusterFSCheckFile;
	}

	/**
	 * 检查GlusterFS是否正常
	 */
	@Override
	public boolean doCheck() {
		File file = new File(glusterFSCheckFile);
		return file.exists();
	}

	public String getGlusterFSCheckFile() {
		return glusterFSCheckFile;
	}

	public void setGlusterFSCheckFile(String glusterFSCheckFile) {
		this.glusterFSCheckFile = glusterFSCheckFile;
	}

}
